import 'dart:async';
import 'dart:math' show pi;
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:yi_shop/components/coupon/painter.dart';
import 'package:yi_shop/extensions/date.dart';
import 'package:yi_shop/utils/colors.dart';
import 'package:yi_shop/utils/radian.dart';
import 'package:yi_shop/utils/styles.dart';
import 'package:yi_shop/utils/tools.dart';

/// 精选
class CouponChoiceController extends GetxController {
  RxInt timeout = (11 * 3600 - 1).obs;

  Timer? _timer;

  @override
  void onInit() {
    _timer = Timer.periodic(const Duration(seconds: 1), (Timer timer) {
      if (timeout.value == 0) {
        return _timer?.cancel();
      }
      timeout--;
    });
    super.onInit();
  }

  @override
  void onClose() {
    clearTimeout();
    super.onClose();
  }

  void clearTimeout() {
    if (_timer != null && _timer!.isActive) {
      _timer?.cancel();
    }
  }
}

class CouponChoiceView extends StatefulWidget {
  const CouponChoiceView({super.key});

  @override
  State<CouponChoiceView> createState() => _CouponChoiceViewState();
}

class _CouponChoiceViewState extends State<CouponChoiceView> {
  late CouponChoiceController controller;

  @override
  void initState() {
    controller = Get.find<CouponChoiceController>();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      padding: EdgeInsets.only(bottom: 20.h),
      child: Column(
        children: [
          Container(
            alignment: Alignment.center,
            margin: const EdgeInsets.only(top: 15),
            child: Container(
              width: 360,
              height: 100,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(5.r),
                color: Colors.white,
              ),
              child: CustomPaint(
                painter: MyCustomPainter(),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      width: 100,
                      alignment: Alignment.center,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(5.r),
                        child: CachedNetworkImage(
                          imageUrl:
                              'https://img.alicdn.com/img/i4/116609430/O1CN01Lfwqz42JWzcklZ8VH_!!0-saturn_solar.jpg_360x360xzq75.jpg_.webp',
                          width: 65,
                          height: 65,
                          fit: BoxFit.fill,
                        ),
                      ),
                    ),
                    Expanded(
                        child: Container(
                      padding: EdgeInsets.only(
                        left: 2.w,
                      ),
                      child: Column(
                        children: [
                          Container(
                            padding: const EdgeInsets.only(top: 10),
                            alignment: Alignment.centerLeft,
                            child: Text(
                              '全品类通用券(除特殊商品)【10/11/12/13点限量抢】',
                              style: StylesUtils.customTextStyle(
                                  fontSize: StylesUtils.fontSize12,
                                  color: ColorsUtils.color6666,
                                  lineHeight: 1.2.h),
                            ),
                          ),
                          Container(
                            margin: EdgeInsets.only(top: 10.h),
                            alignment: Alignment.centerLeft,
                            child: Wrap(
                              spacing: 20.w,
                              crossAxisAlignment: WrapCrossAlignment.center,
                              alignment: WrapAlignment.start,
                              children: [
                                Text(
                                  '5',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: StylesUtils.fontSize20,
                                      color: ColorsUtils.color0000,
                                      fontWeight: FontWeight.w700),
                                ),
                                Text(
                                  '满105可用',
                                  style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color9999,
                                      fontSize: StylesUtils.fontSize12),
                                )
                              ],
                            ),
                          )
                        ],
                      ),
                    )),
                    SizedBox(
                      width: 100,
                      child: Column(
                        children: [
                          Container(
                            padding: const EdgeInsets.only(top: 10, bottom: 4),
                            alignment: Alignment.center,
                            child: Text(
                              '距离开抢还剩',
                              style: StylesUtils.customTextStyle(
                                  color: ColorsUtils.color9999, fontSize: StylesUtils.fontSize12),
                            ),
                          ),
                          Center(
                            child: Obx(() => Text(
                                  durationTransform(controller.timeout.value),
                                  style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color0000,
                                      fontSize: StylesUtils.fontSize13,
                                      fontWeight: FontWeight.w700),
                                )),
                          ),
                          Container(
                            alignment: Alignment.center,
                            margin: const EdgeInsets.only(top: 4, bottom: 4),
                            child: Text(
                              '599已提醒',
                              style: StylesUtils.customTextStyle(
                                  fontSize: StylesUtils.fontSize12, color: ColorsUtils.color9999),
                            ),
                          ),
                          Center(
                            child: Container(
                              alignment: Alignment.center,
                              constraints: const BoxConstraints.expand(width: 78, height: 24),
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(12),
                                color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorF048),
                              ),
                              child: Text(
                                '提醒我',
                                style:
                                    StylesUtils.customTextStyle(fontSize: StylesUtils.fontSize12),
                              ),
                            ),
                          )
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
          Container(
            alignment: Alignment.center,
            margin: const EdgeInsets.only(top: 15),
            child: Container(
              width: 360,
              height: 100,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(5.r),
                color: Colors.white,
              ),
              child: CustomPaint(
                painter: MyCustomPainter(),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      width: 100,
                      alignment: Alignment.center,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(5.r),
                        child: CachedNetworkImage(
                          imageUrl:
                              'https://img.alicdn.com/img/i4/116609430/O1CN01Lfwqz42JWzcklZ8VH_!!0-saturn_solar.jpg_360x360xzq75.jpg_.webp',
                          width: 65,
                          height: 65,
                          fit: BoxFit.fill,
                        ),
                      ),
                    ),
                    Expanded(
                        child: Container(
                      padding: EdgeInsets.only(
                        left: 2.w,
                      ),
                      child: Column(
                        children: [
                          Container(
                            padding: const EdgeInsets.only(top: 10),
                            alignment: Alignment.centerLeft,
                            child: Text(
                              '个人护理部分商品',
                              style: StylesUtils.customTextStyle(
                                  fontSize: StylesUtils.fontSize12,
                                  color: ColorsUtils.color6666,
                                  lineHeight: 1.2.h),
                            ),
                          ),
                          Container(
                            margin: EdgeInsets.only(top: 10.h),
                            alignment: Alignment.centerLeft,
                            child: Wrap(
                              spacing: 20.w,
                              crossAxisAlignment: WrapCrossAlignment.center,
                              alignment: WrapAlignment.start,
                              children: [
                                Text(
                                  '100',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: StylesUtils.fontSize20,
                                      color: ColorsUtils.color0000,
                                      fontWeight: FontWeight.w700),
                                ),
                                Text(
                                  '满105可用',
                                  style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color9999,
                                      fontSize: StylesUtils.fontSize12),
                                )
                              ],
                            ),
                          )
                        ],
                      ),
                    )),
                    SizedBox(
                      width: 100,
                      child: Column(
                        children: [
                          Container(
                            margin: const EdgeInsets.only(top: 10),
                            alignment: Alignment.center,
                            child: SizedBox(
                              width: 51,
                              height: 51,
                              child: CustomPaint(
                                painter: MyCircular(),
                                child: Column(
                                  children: [
                                    Container(
                                      margin: const EdgeInsets.only(top: 10),
                                      alignment: Alignment.center,
                                      child: Text(
                                        '已抢',
                                        style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.colorF048,
                                            fontSize: StylesUtils.fontSize10,
                                            fontWeight: FontWeight.w700),
                                      ),
                                    ),
                                    Container(
                                      alignment: Alignment.center,
                                      margin: const EdgeInsets.only(top: 5),
                                      child: Text(
                                        '23%',
                                        style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.colorF048,
                                            fontSize: StylesUtils.fontSize10,
                                            fontWeight: FontWeight.w700),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                            ),
                          ),
                          Container(
                            margin: const EdgeInsets.only(top: 10),
                            alignment: Alignment.center,
                            child: Container(
                              alignment: Alignment.center,
                              constraints: const BoxConstraints.expand(width: 78, height: 24),
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(12),
                                color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorF048),
                              ),
                              child: Text(
                                '立即领取',
                                style:
                                    StylesUtils.customTextStyle(fontSize: StylesUtils.fontSize12),
                              ),
                            ),
                          )
                        ],
                      ),
                    )
                  ],
                ),
              ),
            ),
          ),
          Container(
            alignment: Alignment.center,
            margin: const EdgeInsets.only(top: 15),
            child: Container(
              width: 360,
              height: 100,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(5.r),
                color: Colors.white,
              ),
              child: CustomPaint(
                painter: MyCustomPainter(),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      width: 100,
                      alignment: Alignment.center,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(5.r),
                        child: CachedNetworkImage(
                          imageUrl:
                              'https://img.alicdn.com/img/i4/116609430/O1CN01Lfwqz42JWzcklZ8VH_!!0-saturn_solar.jpg_360x360xzq75.jpg_.webp',
                          width: 65,
                          height: 65,
                          fit: BoxFit.fill,
                        ),
                      ),
                    ),
                    Expanded(
                        child: Container(
                      padding: EdgeInsets.only(
                        left: 2.w,
                      ),
                      child: Column(
                        children: [
                          Container(
                            padding: const EdgeInsets.only(top: 10),
                            alignment: Alignment.centerLeft,
                            child: Text(
                              '个人护理部分商品',
                              style: StylesUtils.customTextStyle(
                                  fontSize: StylesUtils.fontSize12,
                                  color: ColorsUtils.color6666,
                                  lineHeight: 1.2.h),
                            ),
                          ),
                          Container(
                            margin: EdgeInsets.only(top: 10.h),
                            alignment: Alignment.centerLeft,
                            child: Wrap(
                              spacing: 20.w,
                              crossAxisAlignment: WrapCrossAlignment.center,
                              alignment: WrapAlignment.start,
                              children: [
                                Text(
                                  '100',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: StylesUtils.fontSize20,
                                      color: ColorsUtils.color0000,
                                      fontWeight: FontWeight.w700),
                                ),
                                Text(
                                  '满105可用',
                                  style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color9999,
                                      fontSize: StylesUtils.fontSize12),
                                )
                              ],
                            ),
                          )
                        ],
                      ),
                    )),
                    SizedBox(
                      width: 100,
                      child: Column(
                        children: [
                          Container(
                            margin: const EdgeInsets.only(top: 10),
                            alignment: Alignment.center,
                            child: SizedBox(
                              width: 51,
                              height: 51,
                              child: CustomPaint(
                                painter: MyCircular(),
                                child: Column(
                                  children: [
                                    Container(
                                      margin: const EdgeInsets.only(top: 10),
                                      alignment: Alignment.center,
                                      child: Text(
                                        '已抢',
                                        style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.colorF048,
                                            fontSize: StylesUtils.fontSize10,
                                            fontWeight: FontWeight.w700),
                                      ),
                                    ),
                                    Container(
                                      alignment: Alignment.center,
                                      margin: const EdgeInsets.only(top: 5),
                                      child: Text(
                                        '23%',
                                        style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.colorF048,
                                            fontSize: StylesUtils.fontSize10,
                                            fontWeight: FontWeight.w700),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                            ),
                          ),
                          Container(
                            margin: const EdgeInsets.only(top: 10),
                            alignment: Alignment.center,
                            child: Container(
                              alignment: Alignment.center,
                              constraints: const BoxConstraints.expand(width: 78, height: 24),
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(12),
                                color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorF048),
                              ),
                              child: Text(
                                '立即领取',
                                style:
                                    StylesUtils.customTextStyle(fontSize: StylesUtils.fontSize12),
                              ),
                            ),
                          )
                        ],
                      ),
                    )
                  ],
                ),
              ),
            ),
          ),
          Container(
            alignment: Alignment.center,
            margin: const EdgeInsets.only(top: 15),
            child: Container(
              width: 360,
              height: 100,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(5.r),
                color: Colors.white,
              ),
              child: CustomPaint(
                painter: MyCustomPainter(),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      width: 100,
                      alignment: Alignment.center,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(5.r),
                        child: CachedNetworkImage(
                          imageUrl:
                              'https://img.alicdn.com/img/i4/116609430/O1CN01Lfwqz42JWzcklZ8VH_!!0-saturn_solar.jpg_360x360xzq75.jpg_.webp',
                          width: 65,
                          height: 65,
                          fit: BoxFit.fill,
                        ),
                      ),
                    ),
                    Expanded(
                        child: Container(
                      padding: EdgeInsets.only(
                        left: 2.w,
                      ),
                      child: Column(
                        children: [
                          Container(
                            padding: const EdgeInsets.only(top: 10),
                            alignment: Alignment.centerLeft,
                            child: Text(
                              '个人护理部分商品',
                              style: StylesUtils.customTextStyle(
                                  fontSize: StylesUtils.fontSize12,
                                  color: ColorsUtils.color6666,
                                  lineHeight: 1.2.h),
                            ),
                          ),
                          Container(
                            margin: EdgeInsets.only(top: 10.h),
                            alignment: Alignment.centerLeft,
                            child: Wrap(
                              spacing: 20.w,
                              crossAxisAlignment: WrapCrossAlignment.center,
                              alignment: WrapAlignment.start,
                              children: [
                                Text(
                                  '100',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: StylesUtils.fontSize20,
                                      color: ColorsUtils.color0000,
                                      fontWeight: FontWeight.w700),
                                ),
                                Text(
                                  '满105可用',
                                  style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color9999,
                                      fontSize: StylesUtils.fontSize12),
                                )
                              ],
                            ),
                          )
                        ],
                      ),
                    )),
                    SizedBox(
                      width: 100,
                      child: Column(
                        children: [
                          Container(
                            margin: const EdgeInsets.only(top: 10),
                            alignment: Alignment.center,
                            child: SizedBox(
                              width: 51,
                              height: 51,
                              child: CustomPaint(
                                painter: MyCircular(),
                                child: Column(
                                  children: [
                                    Container(
                                      margin: const EdgeInsets.only(top: 10),
                                      alignment: Alignment.center,
                                      child: Text(
                                        '已抢',
                                        style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.colorF048,
                                            fontSize: StylesUtils.fontSize10,
                                            fontWeight: FontWeight.w700),
                                      ),
                                    ),
                                    Container(
                                      alignment: Alignment.center,
                                      margin: const EdgeInsets.only(top: 5),
                                      child: Text(
                                        '23%',
                                        style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.colorF048,
                                            fontSize: StylesUtils.fontSize10,
                                            fontWeight: FontWeight.w700),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                            ),
                          ),
                          Container(
                            margin: const EdgeInsets.only(top: 10),
                            alignment: Alignment.center,
                            child: Container(
                              alignment: Alignment.center,
                              constraints: const BoxConstraints.expand(width: 78, height: 24),
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(12),
                                color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorF048),
                              ),
                              child: Text(
                                '立即领取',
                                style:
                                    StylesUtils.customTextStyle(fontSize: StylesUtils.fontSize12),
                              ),
                            ),
                          )
                        ],
                      ),
                    )
                  ],
                ),
              ),
            ),
          ),
          Container(
            alignment: Alignment.center,
            margin: const EdgeInsets.only(top: 15),
            child: Container(
              width: 360,
              height: 100,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(5.r),
                color: Colors.white,
              ),
              child: CustomPaint(
                painter: MyCustomPainter(),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      width: 100,
                      alignment: Alignment.center,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(5.r),
                        child: CachedNetworkImage(
                          imageUrl:
                              'https://img.alicdn.com/img/i4/116609430/O1CN01Lfwqz42JWzcklZ8VH_!!0-saturn_solar.jpg_360x360xzq75.jpg_.webp',
                          width: 65,
                          height: 65,
                          fit: BoxFit.fill,
                        ),
                      ),
                    ),
                    Expanded(
                        child: Container(
                      padding: EdgeInsets.only(
                        left: 2.w,
                      ),
                      child: Column(
                        children: [
                          Container(
                            padding: const EdgeInsets.only(top: 10),
                            alignment: Alignment.centerLeft,
                            child: Text(
                              '个人护理部分商品',
                              style: StylesUtils.customTextStyle(
                                  fontSize: StylesUtils.fontSize12,
                                  color: ColorsUtils.color6666,
                                  lineHeight: 1.2.h),
                            ),
                          ),
                          Container(
                            margin: EdgeInsets.only(top: 10.h),
                            alignment: Alignment.centerLeft,
                            child: Wrap(
                              spacing: 20.w,
                              crossAxisAlignment: WrapCrossAlignment.center,
                              alignment: WrapAlignment.start,
                              children: [
                                Text(
                                  '100',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: StylesUtils.fontSize20,
                                      color: ColorsUtils.color0000,
                                      fontWeight: FontWeight.w700),
                                ),
                                Text(
                                  '满105可用',
                                  style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color9999,
                                      fontSize: StylesUtils.fontSize12),
                                )
                              ],
                            ),
                          )
                        ],
                      ),
                    )),
                    SizedBox(
                      width: 100,
                      child: Column(
                        children: [
                          Container(
                            margin: const EdgeInsets.only(top: 10),
                            alignment: Alignment.center,
                            child: SizedBox(
                              width: 51,
                              height: 51,
                              child: CustomPaint(
                                painter: MyCircular(),
                                child: Column(
                                  children: [
                                    Container(
                                      margin: const EdgeInsets.only(top: 10),
                                      alignment: Alignment.center,
                                      child: Text(
                                        '已抢',
                                        style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.colorF048,
                                            fontSize: StylesUtils.fontSize10,
                                            fontWeight: FontWeight.w700),
                                      ),
                                    ),
                                    Container(
                                      alignment: Alignment.center,
                                      margin: const EdgeInsets.only(top: 5),
                                      child: Text(
                                        '23%',
                                        style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.colorF048,
                                            fontSize: StylesUtils.fontSize10,
                                            fontWeight: FontWeight.w700),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                            ),
                          ),
                          Container(
                            margin: const EdgeInsets.only(top: 10),
                            alignment: Alignment.center,
                            child: Container(
                              alignment: Alignment.center,
                              constraints: const BoxConstraints.expand(width: 78, height: 24),
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(12),
                                color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorF048),
                              ),
                              child: Text(
                                '立即领取',
                                style:
                                    StylesUtils.customTextStyle(fontSize: StylesUtils.fontSize12),
                              ),
                            ),
                          )
                        ],
                      ),
                    )
                  ],
                ),
              ),
            ),
          ),
          Container(
            alignment: Alignment.center,
            margin: const EdgeInsets.only(top: 15),
            child: Container(
              width: 360,
              height: 100,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(5.r),
                color: Colors.white,
              ),
              child: CustomPaint(
                painter: MyCustomPainter(),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Expanded(
                        child: Container(
                            padding: const EdgeInsets.only(left: 0, top: 10),
                            alignment: Alignment.centerLeft,
                            child: Column(
                              children: [
                                Wrap(
                                  spacing: 12,
                                  crossAxisAlignment: WrapCrossAlignment.center,
                                  alignment: WrapAlignment.start,
                                  children: [
                                    ClipRRect(
                                      borderRadius: BorderRadius.circular(5.r),
                                      child: CachedNetworkImage(
                                        imageUrl:
                                            'https://img.alicdn.com/img/i2/109528351/O1CN015I6OMK2BYoTXWqVfB_!!0-saturn_solar.jpg_360x360xzq75.jpg_.webp',
                                        width: 70,
                                        height: 65,
                                        fit: BoxFit.fill,
                                      ),
                                    ),
                                    ClipRRect(
                                      borderRadius: BorderRadius.circular(5.r),
                                      child: CachedNetworkImage(
                                        imageUrl:
                                            'https://img.alicdn.com/img/i2/109528351/O1CN015I6OMK2BYoTXWqVfB_!!0-saturn_solar.jpg_360x360xzq75.jpg_.webp',
                                        width: 70,
                                        height: 65,
                                        fit: BoxFit.fill,
                                      ),
                                    ),
                                    ClipRRect(
                                      borderRadius: BorderRadius.circular(5.r),
                                      child: CachedNetworkImage(
                                        imageUrl:
                                            'https://img.alicdn.com/img/i2/109528351/O1CN015I6OMK2BYoTXWqVfB_!!0-saturn_solar.jpg_360x360xzq75.jpg_.webp',
                                        width: 70,
                                        height: 65,
                                        fit: BoxFit.fill,
                                      ),
                                    ),
                                  ],
                                ),
                                Container(
                                  alignment: Alignment.centerLeft,
                                  margin: const EdgeInsets.only(top: 5, left: 12),
                                  child: Wrap(
                                    spacing: 20,
                                    children: [
                                      Text(
                                        '满99减40',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: StylesUtils.fontSize12,
                                            color: ColorsUtils.color0000),
                                      ),
                                      Text(
                                        '音响耳机品类店铺指定商品',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: StylesUtils.fontSize12,
                                            color: ColorsUtils.color9999),
                                      )
                                    ],
                                  ),
                                )
                              ],
                            ))),
                    SizedBox(
                      width: 100,
                      child: Column(
                        children: [
                          Container(
                            margin: const EdgeInsets.only(top: 20),
                            alignment: Alignment.center,
                            child: Container(
                                constraints: const BoxConstraints.expand(width: 40, height: 40),
                                decoration: BoxDecoration(
                                  image: DecorationImage(
                                      image: ToolsUtils.assetImage('u7344.png'), fit: BoxFit.fill),
                                ),
                                alignment: Alignment.center,
                                child: Transform.rotate(
                                  // angle: pi / 4,
                                  angle: RadianUtils.angleToRadian(45),
                                  child: Text(
                                    '已使用',
                                    style: StylesUtils.customTextStyle(
                                        color: ColorsUtils.color9999,
                                        fontSize: StylesUtils.fontSize8),
                                  ),
                                )),
                          ),
                          Container(
                            margin: const EdgeInsets.only(top: 10),
                            alignment: Alignment.center,
                            child: Container(
                              alignment: Alignment.center,
                              constraints: const BoxConstraints.expand(width: 78, height: 24),
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(12),
                                color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorF26f),
                              ),
                              child: Text(
                                '去使用',
                                style:
                                    StylesUtils.customTextStyle(fontSize: StylesUtils.fontSize12),
                              ),
                            ),
                          )
                        ],
                      ),
                    )
                  ],
                ),
              ),
            ),
          ),
          Container(
            alignment: Alignment.center,
            margin: const EdgeInsets.only(top: 15),
            child: Container(
              width: 360,
              height: 100,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(5.r),
                color: Colors.white,
              ),
              child: CustomPaint(
                painter: MyCustomPainter(),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Expanded(
                        child: Container(
                            padding: const EdgeInsets.only(left: 0, top: 10),
                            alignment: Alignment.centerLeft,
                            child: Column(
                              children: [
                                Wrap(
                                  spacing: 12,
                                  crossAxisAlignment: WrapCrossAlignment.center,
                                  alignment: WrapAlignment.start,
                                  children: [
                                    ClipRRect(
                                      borderRadius: BorderRadius.circular(5.r),
                                      child: CachedNetworkImage(
                                        imageUrl:
                                        'https://img.alicdn.com/img/i2/109528351/O1CN015I6OMK2BYoTXWqVfB_!!0-saturn_solar.jpg_360x360xzq75.jpg_.webp',
                                        width: 70,
                                        height: 65,
                                        fit: BoxFit.fill,
                                      ),
                                    ),
                                    ClipRRect(
                                      borderRadius: BorderRadius.circular(5.r),
                                      child: CachedNetworkImage(
                                        imageUrl:
                                        'https://img.alicdn.com/img/i2/109528351/O1CN015I6OMK2BYoTXWqVfB_!!0-saturn_solar.jpg_360x360xzq75.jpg_.webp',
                                        width: 70,
                                        height: 65,
                                        fit: BoxFit.fill,
                                      ),
                                    ),
                                    ClipRRect(
                                      borderRadius: BorderRadius.circular(5.r),
                                      child: CachedNetworkImage(
                                        imageUrl:
                                        'https://img.alicdn.com/img/i2/109528351/O1CN015I6OMK2BYoTXWqVfB_!!0-saturn_solar.jpg_360x360xzq75.jpg_.webp',
                                        width: 70,
                                        height: 65,
                                        fit: BoxFit.fill,
                                      ),
                                    ),
                                  ],
                                ),
                                Container(
                                  alignment: Alignment.centerLeft,
                                  margin: const EdgeInsets.only(top: 5, left: 12),
                                  child: Wrap(
                                    spacing: 20,
                                    children: [
                                      Text(
                                        '满99减40',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: StylesUtils.fontSize12,
                                            color: ColorsUtils.color0000),
                                      ),
                                      Text(
                                        '音响耳机品类店铺指定商品',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: StylesUtils.fontSize12,
                                            color: ColorsUtils.color9999),
                                      )
                                    ],
                                  ),
                                )
                              ],
                            ))),
                    SizedBox(
                      width: 100,
                      child: Column(
                        children: [
                          Container(
                            margin: const EdgeInsets.only(top: 20),
                            alignment: Alignment.center,
                            child: Container(
                                constraints: const BoxConstraints.expand(width: 40, height: 40),
                                decoration: BoxDecoration(
                                  image: DecorationImage(
                                      image: ToolsUtils.assetImage('u7344.png'), fit: BoxFit.fill),
                                ),
                                alignment: Alignment.center,
                                child: Transform.rotate(
                                  angle: pi / 4,
                                  child: Text(
                                    '已使用',
                                    style: StylesUtils.customTextStyle(
                                        color: ColorsUtils.color9999,
                                        fontSize: StylesUtils.fontSize8),
                                  ),
                                )),
                          ),
                          Container(
                            margin: const EdgeInsets.only(top: 10),
                            alignment: Alignment.center,
                            child: Container(
                              alignment: Alignment.center,
                              constraints: const BoxConstraints.expand(width: 78, height: 24),
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(12),
                                color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorF26f),
                              ),
                              child: Text(
                                '去使用',
                                style:
                                StylesUtils.customTextStyle(fontSize: StylesUtils.fontSize12),
                              ),
                            ),
                          )
                        ],
                      ),
                    )
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<CouponChoiceController>();
    super.dispose();
  }

  String durationTransform(int seconds) {
    if (seconds > 0) {
      return Duration(seconds: seconds).toZhString();
    }
    return '00:00:00';
  }
}

